<div class="registration-form">
	<h3 class="popup-title">Регистрация на сайте</h3>
	<div class="registration-form__inner">
		<?php
		$form = $this->beginWidget('CActiveForm', array(
			'id' => 'registration-form',
			'action' => '/main/ajax/registration',
			'enableAjaxValidation' => true,
			'clientOptions' => array(
				'validateOnSubmit' => true,
			),
		));
		?>

		<fieldset>
			<div class="registration-form__left">
				<div class="registration-form__left__inner">
					<ul>
						<li>
							<div class="type-text">
								<?php echo $form->textField($model, 'userEmail', array('placeholder' => 'Логин')); ?>								
							</div>
						</li>
						<li>
							<div class="type-text">
								<?php echo $form->passwordField($model, 'userPassword', array('placeholder' => 'Пароль')); ?>								
							</div>
						</li>
						<li>
							<div class="type-text">
								<?php echo $form->passwordField($model, 'confirmPassword', array('placeholder' => 'Подтвердите пароль')); ?>								
							</div>
						</li>
					</ul>
				</div>	
			</div>
			<div class="registration-form__right">
				<div class="registration-form__right__inner">
					<ul>
						<?php if (CCaptcha::checkRequirements()): ?>
							<li>
								<div class="captcha" id="captcha">
									<?php $this->widget('CCaptcha'); ?>
								</div>
							</li>
							<li>
								<div class="type-text">
									<?php echo $form->textField($model, 'verifyCode', array('placeholder' => 'Введите пароль с картинки')); ?>									
								</div>
							</li>
						<?php endif; ?>
						<li>
							<div class="checkbox">
								<?php echo $form->checkBox($model, 'terms', array('uncheckValue' => NULL)); ?>								
								<label for="Registration_terms">
									<span class="checkbox__box">
										<span class="checkbox__box__inner">&nbsp;</span>
									</span>    
									<span class="checkbox__text">Я принимаю<br /> <a href="#">условия пользовательского<br /> соглашения</a></span>
								</label>
							</div>
						</li>
					</ul>
				</div>	
			</div>
		</fieldset>
		<fieldset class="center">
			<div style="display: block; text-align: left;color: #FF7777;
				 font: italic 15px 'Georgia',sans-serif;
				 ">
					 <?php echo $form->error($model, 'userEmail'); ?>
					 <?php echo $form->error($model, 'userPassword'); ?>
					 <?php echo $form->error($model, 'confirmPassword'); ?>
					 <?php echo $form->error($model, 'verifyCode'); ?>
					 <?php echo $form->error($model, 'terms'); ?>
			</div>
			<br />
			<p>Все поля обязательны для заполнения</p>
			<div class="type-submit">
				<?php echo CHtml::submitButton('Регистрация'); ?>				
			</div> 
		</fieldset>
		<?php $this->endWidget(); ?>
	</div>
	<div class="social-network">
		<dl>
			<dt>Войти через соц, сети:</dt>
			<dd id="social-net">
				
			</dd>
		</dl>
	</div>
</div>
<style>
	#yw0_button {
		content: ' ';
		background: url("/themes/front/assets/images/recaptcha.png") no-repeat scroll 3px center rgba(0, 0, 0, 0);
		text-decoration: none;
		padding-bottom: 31px;
	}
</style>
<script type="text/javascript">
	/*&lt;![CDATA[*/
	
	$(document).ready(function() {
		$("#social-net").html($("#uLogin").clone());		
		$("#social-net div").css('display', 'block');				
	});
	
	jQuery('#captcha').append('<a href="#" id="yw0_button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>');
	jQuery(document).on('click', '#yw0_button', function() {
		jQuery.ajax({
			url: "\/main\/ajax\/captcha?refresh=1",
			dataType: 'json',
			cache: false,
			success: function(data) {
				jQuery('#captcha #yw0').attr('src', data['url']);
				jQuery('body').data('captcha.hash', [data['hash1'], data['hash2']]);
			}
		});
		return false;
	});

	jQuery('#registration-form').yiiactiveform({'validateOnSubmit': true,
		'afterValidate':
				function(form, data, hasError) {
					if (!hasError) {
						$.ajax({
							type: "POST",
							url: form[0].action,
							data: $(form).serialize(),
							success: function(ret) {
								$('.fancybox-close').trigger('click');
								mobi03.showMessage('Поздравляем Вас с регистрацией', 'Вы успешно зарегистрированы, теперь Вы можете войти на сайт использую Ваш email и пароль.');
							}
						});
					}
				}, 'attributes': [{'id': 'Registration_userEmail', 'inputID': 'Registration_userEmail', 'errorID': 'Registration_userEmail_em_', 'model': 'Registration', 'name': 'userEmail', 'enableAjaxValidation': true}, {'id': 'Registration_userPassword', 'inputID': 'Registration_userPassword', 'errorID': 'Registration_userPassword_em_', 'model': 'Registration', 'name': 'userPassword', 'enableAjaxValidation': true}, {'id': 'Registration_confirmPassword', 'inputID': 'Registration_confirmPassword', 'errorID': 'Registration_confirmPassword_em_', 'model': 'Registration', 'name': 'confirmPassword', 'enableAjaxValidation': true}, {'id': 'Registration_verifyCode', 'inputID': 'Registration_verifyCode', 'errorID': 'Registration_verifyCode_em_', 'model': 'Registration', 'name': 'verifyCode', 'enableAjaxValidation': true}, {'id': 'Registration_terms', 'inputID': 'Registration_terms', 'errorID': 'Registration_terms_em_', 'model': 'Registration', 'name': 'terms', 'enableAjaxValidation': true}], 'errorCss': 'error'});
	/*]]&gt;*/
</script>